<template>

  <MGlNetworkResourceModal ref="mglNetworkResourceModal"></MGlNetworkResourceModal>
  <MGlStorageResourcesModal ref="mglStorageResourcesModal"></MGlStorageResourcesModal>
  <MGlRegulatorModal ref="mglRegulatorModal"></MGlRegulatorModal>
  <MGlComputingResourceModal ref="mglComputingResourceModal"></MGlComputingResourceModal>
  <MGlDriveCabinetModal ref="mglDriveCabinetModal"></MGlDriveCabinetModal>
  <MGlPeripheralModal ref="mglPeripheralModal"></MGlPeripheralModal>
  <MGlOtherItEquipmentModal ref="mglOtherItEquipmentModal"></MGlOtherItEquipmentModal>

  <MPhysicalServerDialog ref="monitoringInfoDialog"/>
  <MNetworkResourceDialog ref="mNetworkResourceDialog"/>
  <MStorageResourcesDialog ref="mStorageResourcesDialog"/>
</template>
<script setup>

import MGlNetworkResourceModal from '/@/views/admin/zygl/components/MGlNetworkResourceModal.vue';
import MGlStorageResourcesModal from '/@/views/admin/zygl/components/MGlStorageResourcesModal.vue';
import MGlRegulatorModal from '/@/views/admin/zygl/components/MGlRegulatorModal.vue';
import MGlComputingResourceModal from '/@/views/admin/zygl/components/MGlComputingResourceModal.vue';
import MGlDriveCabinetModal from '/@/views/admin/zygl/components/MGlDriveCabinetModal.vue';
import MGlPeripheralModal from '/@/views/admin/zygl/components/MGlPeripheralModal.vue';
import MGlOtherItEquipmentModal from '/@/views/admin/zygl/components/MGlOtherItEquipmentModal.vue';


import MPhysicalServerDialog from '/@/views/admin/zyjk/components/MPhysicalServerDialog.vue';
import MNetworkResourceDialog from '/@/views/admin/zyjk/components/MNetworkResourceDialog.vue';
import MStorageResourcesDialog from '/@/views/admin/zyjk/components/MStorageResourcesDialog.vue';


import {getResourceInfo, getMonitorInfo} from '/@/api/myApi/gatewayApi'

import {ref} from 'vue';

const mglNetworkResourceModal = ref(null);
const mglStorageResourcesModal = ref(null);
const mglRegulatorModal = ref(null);
const mglComputingResourceModal = ref(null);
const mglDriveCabinetModal = ref(null);
const mglPeripheralModal = ref(null);
const mglOtherItEquipmentModal = ref(null);

const monitoringInfoDialog = ref(null)
const mNetworkResourceDialog = ref(null)
const mStorageResourcesDialog = ref(null)

const showInfo = base => {
  getResourceInfo(base).then(res => {
    switch (base.deviceType) {
      case '网络资源':
        mglNetworkResourceModal.value.disableSubmit = false;
        mglNetworkResourceModal.value.edit(res);
        break;
      case '储存系统':
        mglStorageResourcesModal.value.disableSubmit = false;
        mglStorageResourcesModal.value.edit(res);
        break;
      case '控制器':
        mglRegulatorModal.value.disableSubmit = false;
        mglRegulatorModal.value.edit(res);
        break;
      case '安全设备':
        mglPeripheralModal.value.disableSubmit = false;
        mglPeripheralModal.value.edit(res);
        break;
      case '盘柜':
        mglDriveCabinetModal.value.disableSubmit = false;
        mglDriveCabinetModal.value.edit(res);
        break;
      case '计算资源':
        mglComputingResourceModal.value.disableSubmit = false;
        mglComputingResourceModal.value.edit(res);
        break;
      case '其他设备':
        mglOtherItEquipmentModal.value.disableSubmit = false;
        mglOtherItEquipmentModal.value.edit(res);
        break;
    }
  })
}

const showJK = base => {
  getResourceInfo(base).then(res => {
    console.log(res);
    switch (base.deviceType) {
      case '网络资源':
        mNetworkResourceDialog.value.showDialog = true
        mNetworkResourceDialog.value.nameTips.data = res
        break;
      case '储存系统':
        mStorageResourcesDialog.value.showDialog = true
        mStorageResourcesDialog.value.nameTips.data = res
        break;
      case '控制器':
        mStorageResourcesDialog.value.showDialog = true
        mStorageResourcesDialog.value.nameTips.data = res
        break;
      case '计算资源':
        monitoringInfoDialog.value.showDialog = true
        monitoringInfoDialog.value.nameTips.data = res
        break;
    }
  })

}

defineExpose({
  showInfo, showJK
})

</script>
